package com.ch.dream.asynctask;

import org.json.JSONObject;

import android.content.Context;

import com.ch.dream.base.BaseRequestAsyncTask;
import com.ch.dream.bean.ReplyNumBean;
import com.ch.dream.common.CommonRequestUrl;
import com.ch.dream.common.CommonResult;
import com.ch.dream.common.CommonUserInfo;
import com.ch.dream.net.MyHttpAPI;
import com.ch.dream.tools.UtilTools;

public class LoginReplyNumRequstAsyncTask extends BaseRequestAsyncTask {

	private MyHttpAPI myHttpAPI = new MyHttpAPI(CommonRequestUrl.LoginReplyNum);
	public LoginReplyNumRequstAsyncTask(Context context, RequestServerListener requestServerListener){
		super(context, requestServerListener);
	}
	@Override
	protected Object doInBackground(Object... json) {
		try{
			JSONObject jsonObject = myHttpAPI.requestForJson((JSONObject)json[0]);
			ReplyNumBean bean =new ReplyNumBean();
			bean.setJsonObject(jsonObject);
			if(CommonResult.SUCCESS.equals(jsonObject.getString("result"))){
				CommonUserInfo.userId = jsonObject.getString("userId");
				CommonUserInfo.userName = jsonObject.getString("userName");
				CommonUserInfo.password = jsonObject.getString("password");
				UtilTools.setStoryType(jsonObject.getJSONArray("storyType"));
				UtilTools.setStoryModify(jsonObject.getJSONArray("storyModify"));
//				UtilTools.setIntSharedPreferences(context,CommonData.REPLYNUM,"timeNum",NumberTools.stringToInt(bean.getTimeNum()));
//				UtilTools.setIntSharedPreferences(context,CommonData.REPLYNUM,"placeNum",NumberTools.stringToInt(bean.getPlaceNum()));
//				UtilTools.setIntSharedPreferences(context,CommonData.REPLYNUM,"eventNum",NumberTools.stringToInt(bean.getEventNum()));
//				UtilTools.setIntSharedPreferences(context,CommonData.REPLYNUM,"peopleNum",NumberTools.stringToInt(bean.getPeopleNum()));
//				UtilTools.setIntSharedPreferences(context,CommonData.REPLYNUM,"getNum",NumberTools.stringToInt(bean.getGetNum()));
			}
			return jsonObject;
		}catch (Exception e) {
			e.printStackTrace();
		}
		
		return null;
	}
}
